<?php

namespace app\user\controller;

use app\common\respond\HttpApi;
use app\user\logic\UserFactoryLogic;

class UserFactoryController
{
    /**
     * @Description 猪厂选择列表
     * @author: zj
     * @param HttpApi $respond
     * @time 2023/08/31 16:25:41
     * @return null
     */
    public function selectList(HttpApi $respond)
    {
//        $param = [
//            'page' => request()->get('page') ?: 0,
//            'page_size' => request()->get('page_size') ?: 10
//        ];
//        $rule = [
//            'page' => '>=:0',
//            'page_size' => '>:0',
//        ];
//        validate($rule)->check($param);

        $logic = new UserFactoryLogic();
        $userId = request()->user_info['user_id'];
        $data = $logic->getSelectList($userId);

        return $respond->success($data);
    }

    /**
     * @Description 选定猪厂
     * @author: zj
     * @param HttpApi $respond
     * @time 2023/08/31 16:29:19
     * @return null
     */
    public function selectFactory(HttpApi $respond)
    {
        $param = [
            'id' => (int)request()->post("id")
        ];
        $rule = [
            "id" => '>:0'
        ];
        validate($rule)->check($param);

        $logic = new UserFactoryLogic();
        $data = $logic->selectFactory($param['id']);

        return $respond->success($data);
    }
}